#include "stdafx.h"

void Application :: init_inputs()
{
	OIS::ParamList parameters;
	unsigned int windowHandle = 0;
	ostringstream windowHandleString;
	 window -> getCustomAttribute("WINDOW", & windowHandle);
	windowHandleString << windowHandle;
	parameters.insert(make_pair("WINDOW", windowHandleString.str()));
	parameters.insert(make_pair("WINDOW", windowHandleString.str()));
// those settings unhide the cursor (from ogre's wiki snippets)
#if defined OIS_WIN32_PLATFORM
	parameters.insert(make_pair(string("w32mouse"), 	string("DISCL_FOREGROUND" )));
	parameters.insert(make_pair(string("w32mouse"), 	string("DISCL_NONEXCLUSIVE")));
	parameters.insert(make_pair(string("w32keyboard"), 	string("DISCL_FOREGROUND")));
	parameters.insert(make_pair(string("w32keyboard"), 	string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
	parameters.insert(make_pair(string("x11mouse_grab"), 	string("false")));
	parameters.insert(make_pair(string("x11mouse_hide"), 	string("false")));
	parameters.insert(make_pair(string("x11keyboard_grab"), string("false")));
	parameters.insert(make_pair(string("XAutoRepeatOn"), 	string("true")));
#endif
/* ### Inputs Objects ################################################## */
	 inputmanager = OIS::InputManager :: createInputSystem(parameters);
	 keyboard = static_cast<OIS::Keyboard *>
		(inputmanager -> createInputObject(OIS::OISKeyboard, true));
	 mouse = static_cast<OIS::Mouse *>
		(inputmanager -> createInputObject	(OIS::OISMouse, true));
	 mouse -> setEventCallback(this);
	 keyboard -> setEventCallback(this);

}
